LIBS= lib
SRCS= src
BINS= bin
INCS= include
TARGETS= $(BINS)/main.elf
OBJS= $(LIBS)/mctrl.o $(LIBS)/launchpad.o
CFLAGS= -Wall -mmcu=msp430g2231 -pg -O2 -Iinclude/ 
CC=msp430-gcc

target:${TARGETS}

##
# Motor Controller
##
$(LIBS)/launchpad.o: $(SRCS)/launchpad.c $(INCS)/launchpad.h
	mkdir -p lib
	$(CC) -o $(LIBS)/launchpad.o -c $(SRCS)/launchpad.c $(CFLAGS)

##
# Motor Controller
##
$(LIBS)/mctrl.o: $(SRCS)/mctrl.c $(INCS)/mctrl.h
	mkdir -p lib
	$(CC) -o $(LIBS)/mctrl.o -c $(SRCS)/mctrl.c $(CFLAGS)

##
# Main Program
##
$(BINS)/main.elf: $(SRCS)/main.c $(OBJS);
	mkdir -p bin
	$(CC) -o $(BINS)/main.elf $(SRCS)/main.c $(OBJS) $(CFLAGS)

program:
	sudo mspdebug rf2500
# After mspdebug connects to the device:
#   Program it with: 
#       prog main.elf
#   Then execute with by exiting mspdebug or typing:
#       run

clean: 
	rm -fr bin/ lib/

again:
	make clean; make

tar:
	tar -cvzf ti-bot.tar *
